package com.scanner;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 顾志杰
 * @date 2021/3/16-13:27
 */
public class InvokerTable {

    private static ConcurrentHashMap<String/*module*/, Map<String/*cmd*/, Invoker>> invokerTable =
            new ConcurrentHashMap<String/*module*/, Map<String/*cmd*/, Invoker>>();


    public static void addInvoker(String module,String cmd,Invoker invoker) {
        Map<String, Invoker> map = invokerTable.computeIfAbsent(module, k -> new HashMap<>());
        map.put(cmd,invoker);
    }

    public static Invoker getInvoker(String module,String cmd){
        Map<String, Invoker> map = invokerTable.get(module);
        if(map != null){
            return map.get(cmd);
        }
        return null;
    }
}
